Imports System.Data.OracleClient

Public Class clsManageCategory

  Private mCmdData As OracleCommand

  Public Function PopulateAllCategory() As OracleDataReader

    Dim lStrQuery As String = String.Empty
    Dim lObjRtn As OracleDataReader

    mPrRefreshConn()

    lStrQuery = "SELECT  * FROM TRDX_DATA_CATEGORY_MSTR T"

    mCmdData = New OracleCommand(lStrQuery, con)
    lObjRtn = mCmdData.ExecuteReader

    Return lObjRtn

  End Function

  Public Function CheckCategory(ByVal aStrDataCategory As String, _
                                ByVal aStrFEDBCategory As String, _
                                ByVal aStrBEDBCategory As String, _
                                ByVal aStrFECategory As String, _
                                ByVal aStrBEDataType As String) As Integer
    Dim lStrQuery As String = String.Empty
    Dim lIntRtn As Integer

    lStrQuery = "SELECT COUNT(*) FROM TRDX_DATA_CATEGORY_MSTR " & _
                  " WHERE TDCM_DATA_CTGRY = '" & aStrDataCategory & "'" & _
                  " AND TDCM_FRNT_END_DATA_TYPE = '" & aStrFEDBCategory & "'" & _
                  " AND TDCM_DATABASE_DATA_TYPE = '" & aStrBEDBCategory & "'" & _
                  " AND TDCM_FRNT_END_DATA_CATEGORY = '" & aStrFECategory & "'" & _
                  " AND TDCM_BACK_END_DATA_TYPE = '" & aStrBEDataType & "'"

    mCmdData = New OracleCommand(lStrQuery, con)
    lIntRtn = mCmdData.ExecuteScalar

    If IsNothing(lIntRtn) Then
      Return 0
    Else
      Return lIntRtn
    End If

  End Function

  Public Sub DeleteCategory(ByVal aStrDataCategory As String, _
                            ByVal aStrFEDBCategory As String, _
                            ByVal aStrBEDBCategory As String, _
                            ByVal aStrFECategory As String, _
                            ByVal aStrBEDataType As String)

    Dim lStrQuery As String = String.Empty

    Try
      lStrQuery = "DELETE FROM TRDX_DATA_CATEGORY_MSTR " & _
                    " WHERE TDCM_DATA_CTGRY = '" & aStrDataCategory & "'" & _
                    " AND TDCM_FRNT_END_DATA_TYPE = '" & aStrFEDBCategory & "'" & _
                    " AND TDCM_DATABASE_DATA_TYPE = '" & aStrBEDBCategory & "'" & _
                    " AND TDCM_FRNT_END_DATA_CATEGORY = '" & aStrFECategory & "'" & _
                    " AND TDCM_BACK_END_DATA_TYPE = '" & aStrBEDataType & "'"

      mCmdData = New OracleCommand(lStrQuery, con)
      mCmdData.ExecuteNonQuery()
    Catch ex As Exception

    End Try

  End Sub

  Public Sub InsertCategory(ByVal aStrCategoryDesc As String, _
                            ByVal aIntLength As Integer, _
                            ByVal aIntPrecision As Integer, _
                            ByVal aStrDataCategory As String, _
                            ByVal aStrFEDBCategory As String, _
                            ByVal aStrBEDBCategory As String, _
                            ByVal aStrFECategory As String, _
                            ByVal aStrBEDataType As String)

    Dim lStrQuery As String = String.Empty

    Try
      lStrQuery = "INSERT INTO TRDX_DATA_CATEGORY_MSTR (TDCM_DESC,TDCM_DATA_LENGTH,TDCM_DATA_PRECISION,TDCM_DATA_CTGRY,TDCM_FRNT_END_DATA_TYPE,TDCM_BACK_END_DATA_TYPE,TDCM_FRNT_END_DATA_CATEGORY,TDCM_DATABASE_DATA_TYPE) " & _
                     " VALUES ('" & aStrCategoryDesc & "'," & aIntLength & "," & aIntPrecision & ",'" & aStrDataCategory & "','" & aStrFEDBCategory & "','" & aStrBEDataType & "','" & aStrFECategory & "','" & aStrBEDBCategory & "')"

      mCmdData = New OracleCommand(lStrQuery, con)
      mCmdData.ExecuteNonQuery()
    Catch ex As Exception

    End Try

  End Sub

  Public Sub UpdateCategory(ByVal aStrCategoryDesc As String, _
                            ByVal aIntLength As Integer, _
                            ByVal aIntPrecision As Integer, _
                            ByVal aStrDataCategory As String, _
                            ByVal aStrFEDBCategory As String, _
                            ByVal aStrBEDBCategory As String, _
                            ByVal aStrFECategory As String, _
                            ByVal aStrBEDataType As String)

    Dim lStrQuery As String = String.Empty

    Try
      lStrQuery = "UPDATE TRDX_DATA_CATEGORY_MSTR SET " & _
                     "TDCM_DESC='" & aStrCategoryDesc & "'," & _
                     "TDCM_DATA_LENGTH=" & aIntLength & "," & _
                     "TDCM_DATA_PRECISION=" & aIntPrecision & "," & _
                     "TDCM_FRNT_END_DATA_TYPE='" & aStrFEDBCategory & "'," & _
                     "TDCM_BACK_END_DATA_TYPE='" & aStrBEDataType & "'," & _
                     "TDCM_FRNT_END_DATA_CATEGORY='" & aStrFECategory & "'," & _
                     "TDCM_DATABASE_DATA_TYPE='" & aStrBEDBCategory & "' WHERE TDCM_DATA_CTGRY = '" & aStrDataCategory & "'"

      mCmdData = New OracleCommand(lStrQuery, con)
      mCmdData.ExecuteNonQuery()

    Catch ex As Exception

    End Try

  End Sub
End Class
